<template>
	<view class="studenthome">
		<view class="headerbg">
			<view class="title">
				首页
			</view>
			<view class="homebox">
				<!-- 搜索框 -->
				<view class="searchbox" @click="gotoSearch">
					<u-icon label="请输入搜索词" size="30" name="search"></u-icon>
					<text class="searchtext"> 搜索</text>
				</view>
				<view class="selectTeacher">
					<view class="title">
						已选择导师
					</view>
					<!-- 未选择导师 -->
					<view v-if="selectedTeacherData.length>0" class="selectitem">
						<scroll-view class="scroll-view_H" scroll-x="true" scroll-left="0">
							<view class="selectitemone" v-for="(item,index) in selectedTeacherData">
								<view class="imgbox">
									<image class="imgboximg" :src="item.teacher.photos.url"></image>
								</view>

								<view class="itemmessage">
									<view class="name">
										<text>{{item.teacher.name}}</text>
										<text
											class="leibie">{{item.teacher.category_text != null ? item.teacher.category_text :''}}</text>
									</view>
									<view class="introduction">
										{{item.teacher.brief_introduction}}
									</view>
									<view class="science">
										<view class="scienceitem" v-for="(subitem,index) in item.teacher.science_ids">
											{{subitem}}
										</view>
									</view>
								</view>
							</view>
						</scroll-view>

						</swiper>
					</view>
					<view v-else class="selectitem">
						<view class="kongingbox">
							<image class="noselectimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/noselect.png"></image>
						</view>
						<view class="mesaage">
							南院/物理系/研2班
						</view>
					</view>
				</view>

				<!-- tabs切换栏 -->
				<scroll-view class="scroll-view_Hs" scroll-x="true" scroll-left="0">
					<view class="itemone" v-for="(item,index) in tabsData">
						{{item.name}}
					</view>
				</scroll-view>

				<scroll-view scroll-y="true" class="scroll-Y" style="height: 750rpx; margin-top: 30rpx;">
					<!-- 导师列表 -->
					<view class="tearchList">
						<view class="tearchListitem" v-for="(item,index) in tearchData" :key="item.id"
							@click="gotoTeacherdetail(item.id)">
							<view class="imgbox">
								<image class="tearchtimg" :src="item.photos.url"></image>
							</view>
							<view class="messagebox">
								<view class="name">
									{{item.name}}
								</view>
								<view class="zhicheng">
									{{item.category_text}}
								</view>
								<view class="zhuanye">
									<view class="zhichengitem" v-for="(subitem,subindex) in item.science_ids"
										:key="subindex">
										{{subitem}}
									</view>
								</view>
							</view>

						</view>
					</view>
					<view class="" style="height: 40rpx;"></view>

				</scroll-view>

			</view>

			<!-- <view class="navbarbox"> -->
			<u-tabbar :value="value1" :fixed="true" :placeholder="false" :safeAreaInsetBottom="true">
				<u-tabbar-item text="首页" icon="home-fill"></u-tabbar-item>
				<u-tabbar-item text="个人中心" icon="account-fill" @click="click1"></u-tabbar-item>
			</u-tabbar>
			<!-- </view> -->
		</view>
	</view>

</template>

<script>
	import {
		getTeacherList,
		getpersonal,
		selectedteacher
	} from "../../api/api.js"
	export default {
		data() {
			return {
				value1: 0,

				tabsData: [

				],
				tearchData: [

				],
				selectedTeacherData: [],
			}
		},
		onLoad() {
			this.getTeacherList()
			this.selectedteachers()
			this.getpersonals()
		},
		methods: {
			async getTeacherList() {
				let res = await getTeacherList({
					page: "1",
					size: "20"
				})
				if (res.code == 1) {
					this.tearchData = res.data
					this.tearchData.forEach((item, index) => {
						item.science_ids = item.science_ids.split(",")
					})
					console.log("导师列表", this.tearchData)
				}
			},
			async selectedteachers() {
				let res = await selectedteacher()
				if (res.code == 1) {
					this.selectedTeacherData = res.data
					this.selectedTeacherData.forEach((item, index) => {
						item.teacher.science_ids = item.teacher.science_ids.split(",")
					})
					console.log("已选择老师", this.selectedTeacherData)
				}
			},
			async getpersonals() {
				let res = await getpersonal()
				if (res.code == 1) {
					console.log("学生信息", res)
					this.tabsData.push({
						name: res.data.science_id_text
					})
					console.log(this.tabsData)

				}
			},
			click1(e) {
				console.log('click1', e);
				this.value1 = e
				uni.redirectTo({
					url: '/pages_students/mine/index'
				})
			},
			gotoSearch() {
				uni.navigateTo({
					url: '../search/index',
				})
			},
			gotoTeacherdetail(id) {
				uni.navigateTo({
					url: `../teacherDetail/index?id=${id}`,
					// url:"../teacherDetail/index"
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	page {
		height: 100%;
		background-color: #F7F8FA;

	}



	.studenthome {
		height: 100vh;
		background-color: #F0F7FF;
		.itemone {
			width: 172rpx;
			height: 60rpx;
			background: #4A9CFF;
			border-radius: 40rpx 40rpx 40rpx 40rpx;
			opacity: 1;
			font-size: 28rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 60rpx;
			text-align: center;
		
		}
		
		.selectitemone {
			width: 100%;
			height: 240rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
		
			.imgbox {
				width: 200rpx;
				height: 240rpx;
		
				.imgboximg {
					width: 200rpx;
					height: 240rpx;
				}
			}
		
			.itemmessage {
				// flex: 1;
				width: 410rpx;
				height: 200rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				z-index: 99999999999999;
		
				.name {
					padding-right: 10rpx;
					font-size: 32rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
					line-height: 38rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
		
					.leibie {
						font-size: 26rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #666666;
						line-height: 30rpx;
					}
				}
		
		
				.introduction {
					font-size: 26rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
					line-height: 30rpx;
					overflow: hidden;
					-webkit-line-clamp: 2;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
				}
			}
		
			.science {
				display: flex;
		
				.scienceitem {
					height: 48rpx;
					background: #F0F7FF;
					border-radius: 12rpx 12rpx 12rpx 12rpx;
					opacity: 1;
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #4A9CFF;
					line-height: 48rpx;
					margin-right: 10rpx;
				}
			}
		}
		
		.scroll-view_Hs {
			white-space: nowrap;
			width: 100%;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			// height: 114rpx;
			margin-top: 20rpx;
		}

		.headerbg {
			width: 750rpx;
			height: 470rpx;
			background: linear-gradient(180deg, #4A9CFF 0%, rgba(74, 156, 255, 0) 100%);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			padding-top: 120rpx;
			box-sizing: border-box;

			.title {
				width: 750rpx;
				height: 65rpx;
				border-radius: 0rpx 0rpx 0rpx 0rpx;
				opacity: 1;
				padding-left: 40rpx;
				box-sizing: border-box;
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 38rpx;
			}

			.homebox {
				padding: 1rpx 30rpx;
				box-sizing: border-box;

				.searchbox {
					width: 690rpx;
					height: 80rpx;
					background: #FFFFFF;
					border-radius: 200rpx 200rpx 200rpx 200rpx;
					margin-top: 10rpx;
					line-height: 80rpx;
					padding-left: 20rpx;
					padding-right: 4rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.searchtext {
						width: 156rpx;
						height: 72rpx;
						background: #4A9CFF;
						border-radius: 200rpx 200rpx 200rpx 200rpx;
						opacity: 1;
						display: inline-block;
						font-size: 30rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #FFFFFF;
						line-height: 42rpx;
						text-align: center;
						line-height: 72rpx;
					}
				}

				.selectTeacher {
					width: 690rpx;
					height: 364rpx;
					background: #FFFFFF;
					box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(206, 220, 237, 0.2);
					border-radius: 30rpx 30rpx 30rpx 30rpx;
					opacity: 1;
					margin-top: 24rpx;
					padding: 30rpx;
					box-sizing: border-box;

					.title {
						font-size: 32rpx;
						font-family: PingFang SC-Bold, PingFang SC;
						font-weight: bold;
						color: #333333;
						line-height: 38rpx;
					}

					.selectitem {
						width: 100%;
						height: 100%;
						display: flex;
						flex-direction: column;
						align-items: center;
						// justify-content: space-between;

						// .scroll-view_H {
						// 	display: flex;
						// }

						.kongingbox {
							width: 172rpx;
							height: 172rpx;

							.noselectimg {
								width: 100%;
								height: 100%;
							}
						}

						.mesaage {
							font-size: 26rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							color: #666666;
							line-height: 30rpx;
						}
					}
				}

				.tearchList {
					width: 100%;
					display: flex;
					justify-content: space-between;
					flex-wrap: wrap;
					margin-top: 20rpx;


					.tearchListitem {
						width: 336rpx;
						height: 562rpx;
						background: #FFFFFF;
						box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(206, 220, 237, 0.2);
						border-radius: 30rpx 30rpx 30rpx 30rpx;
						margin-bottom: 30rpx;
						// display: flex;


						.imgbox {
							width: 336rpx;
							height: 360rpx;

							.tearchtimg {
								width: 100%;
								height: 100%;
								border-radius: 30rpx 30rpx 30rpx 30rpx;
							}

						}

						.messagebox {
							width: 100%;
							height: 200rpx;
							display: flex;
							flex-direction: column;
							justify-content:space-around;
							.name {
								width: 100%;
								font-size: 32rpx;
								font-family: PingFang SC-Bold, PingFang SC;
								font-weight: bold;
								color: #333333;
								line-height: 50rpx;
								margin-left: 20rpx;
								white-space: nowrap;
								overflow: hidden;
								text-overflow: ellipsis;
							}

							.zhicheng {
								font-size: 26rpx;
								font-family: PingFang SC-Regular, PingFang SC;
								font-weight: 400;
								color: #666666;
								line-height: 40rpx;
								margin-left: 20rpx;
							}

							.zhuanye {
								margin-left: 20rpx;
								display: flex;
								width: 90%;
								flex-wrap: wrap;


								.zhichengitem {
									// padding: 0 3rpx;
									height: 48rpx;
									background: #F0F7FF;
									border-radius: 12rpx 12rpx 12rpx 12rpx;
									font-size: 24rpx;
									font-family: PingFang SC-Regular, PingFang SC;
									font-weight: 400;
									color: #4A9CFF;
									line-height: 28rpx;
									text-align: center;
									line-height: 48rpx;
									margin-right: 10rpx;
								}
							}
						}



					}

				}
			}

		}
	}
	
	
	.teacherhome{
		
	}
	
	
</style>